<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>10_自定义JS对象</title>
</head>
<body>
    <table border="1px">
        <tr>
            <th>商品名称</th>
            <th>商品价格</th>
            <th>商品库存</th>
        </tr>
    </table>
<!--    <button onclick="f1()">刷新</button>-->
    <script>
        // function f1(){
        let table=document.querySelector('table')
        let productArr=[
            {title:'小米14',price:8000,num:500},
            {title: '苹果16',price: 10000,num:400},
            {title:'魅族60',price: 2000,num:600 },
            {title: '华为70',price: 6700,num:900}
        ];
        for (let i = 0; i < productArr.length; i++) {
            let data=document.createElement('tr')
            let data1=document.createElement('td')
            let data2=document.createElement('td')
            let data3=document.createElement('td')
            data1.innerHTML=productArr[i].title;
            data2.innerHTML=productArr[i].price;
            data3.innerHTML=productArr[i].num;
            data.append(data1,data2,data3);
            table.append(data);

        }
        // }
        let p1={
            name:'张三',
            age:18,
            say:function (){
                console.log('我是'+this.name+',今年'+this.age+'岁')
            }



        };
        p1.say();
        console.log(p1)
        let p2={};
        p2.name='张三';
        p2.age=18;
        p2.say=function (){
            console.log('我是'+this.name+',今年'+this.age+'岁')

        }
        p2.say();
        console.log(p2)
    </script>
</body>
</html>